package com.fz.mapper;

import com.fz.entity.Book;
import org.apache.ibatis.annotations.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by webrx on 2017/6/13.
 */
public interface BookMapper {
   /* @Select("select * from book")*/
    public List<Book> query();

     @Delete("delete from book where id=#{id}")
    public int deleteById(int id );

     @Update("update book set name=#{nn} where id=#{dd}")
     public int update(@Param("nn") String name,@Param("dd") int id);

     @Update("update book set name=#{name},prive=#{prive} where id=#{id}")
     public int updateAll(Book book);

     @Update("update book set prive=#{prive} where id=#{id}")
     public int updateBu(@Param("prive") double prive,@Param("id") int id);

     @Update("update book set prive=prive+#{prive} where id=#{id}")
     public int updateBU01(@Param("prive") int prive,@Param("id") int id);

     @Update("update book set prive =prive+#{prive} where 1=1")
     public int updateBUAll02(double prive );

     @Select("select * from book where id=#{id}")
     public Book selectByID(int id);

     @Select("select * from book where name like #{name}")
     public List<Book> queryname(String name);

    @Insert("insert into book value(null,#{name},#{prive})")
    public  int save(Book book);

    @Insert("insert into book values(null ,#{nn},#{pp})")
    public int add(@Param("nn") String name,@Param("pp") double prive);


    @Insert("insert into book values(null,#{name},#{price})")
    public int addbook(Map<String,Object> map);

    @Select("select * from book limit #{start}, #{pagesize}")
    public List<Book> page(@Param("start") int start, @Param("pagesize") int pagesize);

    @Select("select name ,prive from book")
    public List<Map<String,Object>> queryNamePrice();


}
